<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

<style type="text/css">
html,body{
	border:0px;
	margin: 0px;
	padding: 0px;
	width: 100%;
	height: 100%;
}
table {
	width:100%;
	border: 1px red solid;
	border-collapse: collapse;
	text-align: center;
}

table tr {
	border: 1px red solid;
}

table tr td {
	border: 1px red solid;
}
</style>

</head>

<body>
	<table>
		<thead>
			<tr>
				<td>ID</td>
				<td>姓名</td>
				<td>性别</td>
				<td>年龄</td>
				<td>状态</td>
				<td>操作</td>
			</tr>
		</thead>
		<tbody id="userTable">
			
		</tbody>
	</table>
</body>
<script type="text/javascript" src="static/JS/jquery.js"></script>
<script type="text/javascript">

	/*********查询所有用户信息**************/
	lastVersionlist();
	function lastVersionlist() {
		$.ajax({
			url : "test/process.do",
			data : "method=findTestUser",
			dataType : "json",
			success : function(data) {
				if (data.status == "SUCCESS") {
					var arrPro = data.data;
					if (arrPro.length > 0) {
						var ptbody = "";
						for ( var i = 0; i < arrPro.length; i++) {
							ptbody += "<tr><td>"+ arrPro[i].id+ "</td><td>"+ arrPro[i].name+ "</td><td>"+ arrPro[i].sex+ "</td><td>"+ arrPro[i].age + "</td><td>"+ arrPro[i].status + "</td><td><a href='javascript:void(0);' onclick='processStart(\""+ arrPro[i].id+ "\");'>提交</a>"+((arrPro[i].status==0?"":"<a href='javascript:void(0);' onclick='findProcessHistoric(\""+ arrPro[i].id+ "\");'>查看</a>"))+"</td></tr>";
						}
						$("#userTable").append(ptbody);
					}
				}
			}
		});
	}

	/*********查询所有流历史版本***************/

	function processStart(id) {
		$.ajax({
			url : "test/process.do",
			data : {
				method:"processStart",
				key:"myProcess",
				businessId:id
			},
			dataType : "json",
			success : function(data) {
				if (data.status == "SUCCESS") {
					console.log(data.text);
				}
			}
		});
	}

	/*********查询执行记录***************/

	function findProcessHistoric(id) {
		$.ajax({
			url : "test/process.do",
			data : {
				method:"findProcessHistoric",
				businessId:id
			},
			dataType : "json",
			success : function(data) {
				if (data.status == "SUCCESS") {
					console.log(data.data);
				}
			}
		});
	}
</script>
</html>
